"use strict";
const common_vendor = require("../../common/vendor.js");
const common_api = require("../../common/api.js");
require("../../common/request.js");
const _sfc_main = {
  data() {
    return {
      backgroundImage: "https://mp-63569ec0-4a37-46d6-b55b-a1d6d8b5ef5a.cdn.bspapp.com/cloudstorage/06319cf1-45b1-464f-8fbc-d867ca28b9b7.png",
      page: 0,
      data: {
        "direction": "",
        "puzzle": "",
        "history": "",
        "question": [-1, -1, -1, -1]
      },
      user: {},
      conversationId: "",
      confirm: false,
      messageText: ""
    };
  },
  onLoad(e) {
    common_vendor.index.showModal({
      title: "心理资料填写提示",
      content: "在开始咨询前，您需要填写一份心理资料，这将有助咨询师更了解您的相关咨询需要",
      success: (res) => {
        if (res.confirm) {
          this.user = common_vendor.index.getStorageSync("user");
          this.conversationId = e.id;
          common_vendor.index.showLoading();
          setTimeout(() => {
            this.confirm = true;
            common_vendor.index.hideLoading();
          }, 500);
        } else {
          common_vendor.index.navigateBack();
        }
      }
    });
  },
  methods: {
    changePage(page) {
      this.page = page;
    },
    toContact() {
      if (!this.data.direction) {
        this.messageText = "咨询方向未填写";
      } else if (!this.data.puzzle) {
        this.messageText = "当前困扰未填写";
      } else if (!this.data.history) {
        this.messageText = "重大影响事件未填写";
      } else if (this.data.question[0] == -1 || this.data.question[1] == -1 || this.data.question[2] == -1 || this.data.question[3] == -1) {
        this.messageText = "当前状态有选项未填写";
      } else {
        common_vendor.index.showLoading({
          title: "提交资料中"
        });
        common_api.putPsychArchive(this.user.id, this.data).then((res) => {
          console.log(res);
          common_vendor.index.hideLoading();
          common_vendor.index.setStorageSync("conversationWaiting", true);
          common_vendor.index.setStorageSync("conversationId", this.conversationId);
          common_vendor.index.reLaunch({
            url: "/pages/consult/consult"
          });
        }).catch((err) => {
          console.log(err);
          common_vendor.index.hideLoading();
        });
        return;
      }
      this.$refs.message.open();
    },
    changeXuanze0(e) {
      this.data.question[0] = parseInt(e);
    },
    changeXuanze1(e) {
      this.data.question[1] = parseInt(e);
    },
    changeXuanze2(e) {
      this.data.question[2] = parseInt(e);
    },
    changeXuanze3(e) {
      this.data.question[3] = parseInt(e);
    }
  }
};
if (!Array) {
  const _easycom_uni_popup_message2 = common_vendor.resolveComponent("uni-popup-message");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  (_easycom_uni_popup_message2 + _easycom_uni_popup2)();
}
const _easycom_uni_popup_message = () => "../../uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.js";
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  (_easycom_uni_popup_message + _easycom_uni_popup)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: $data.confirm
  }, $data.confirm ? common_vendor.e({
    b: common_vendor.o(($event) => $options.changePage(0)),
    c: common_vendor.n($data.page ? "" : "main-page"),
    d: common_vendor.o(($event) => $options.changePage(1)),
    e: common_vendor.n($data.page ? "main-page" : ""),
    f: !$data.page
  }, !$data.page ? {
    g: $data.data.direction,
    h: common_vendor.o(($event) => $data.data.direction = $event.detail.value),
    i: $data.data.puzzle,
    j: common_vendor.o(($event) => $data.data.puzzle = $event.detail.value),
    k: $data.data.history,
    l: common_vendor.o(($event) => $data.data.history = $event.detail.value)
  } : {
    m: common_vendor.o(($event) => $options.changeXuanze0()),
    n: common_vendor.o(($event) => $options.changeXuanze1()),
    o: common_vendor.o(($event) => $options.changeXuanze2()),
    p: common_vendor.o(($event) => $options.changeXuanze3()),
    q: common_vendor.o((...args) => $options.toContact && $options.toContact(...args))
  }, {
    r: common_vendor.s("background-image: url(" + $data.backgroundImage + ");")
  }) : {}, {
    s: common_vendor.p({
      type: "error",
      message: $data.messageText,
      duration: 2e3
    }),
    t: common_vendor.sr("message", "7cbd7f74-0"),
    v: common_vendor.p({
      type: "message"
    })
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "D:/Project/heart-3.0/heart-field-3.0/pages/heart-profile/heart-profile.vue"]]);
wx.createPage(MiniProgramPage);
